
import 'package:async_button/async_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_countdown_timer/flutter_countdown_timer.dart';
import 'package:flutter_countdown_timer/current_remaining_time.dart';
import 'package:flutter_deer/account/models/account_summary_entity.dart';
import 'package:flutter_deer/index/index_router.dart';
import 'package:flutter_deer/index/iview/game_unstart_iview.dart';
import 'package:flutter_deer/index/presenter/game_unstart_presenter.dart';
import 'package:flutter_deer/index/provider/game_unstart_provider.dart';
import 'package:flutter_deer/mvp/base_page.dart';
import 'package:flutter_deer/mvp/power_presenter.dart';
import 'package:flutter_deer/res/constant.dart';
import 'package:flutter_deer/res/resources.dart';
import 'package:flutter_deer/routers/fluro_navigator.dart';
import 'package:flutter_deer/util/image_utils.dart';
import 'package:flutter_deer/util/other_utils.dart';
import 'package:flutter_deer/util/theme_utils.dart';
import 'package:flutter_deer/widgets/fadein_text.dart';
import 'package:flutter_deer/widgets/load_image.dart';
import 'package:flutter_deer/widgets/my_card.dart';
import 'package:flutter_deer/widgets/my_refresh_list.dart';
import 'package:flutter_deer/widgets/my_scroll_view.dart';
import 'package:flutter_deer/widgets/state_layout.dart';
import 'package:flutter_deer/widgets/text_label_item.dart';
import 'package:intl/intl.dart' as nf;
import 'package:lottie/lottie.dart';
import 'package:provider/provider.dart';
import 'package:flutter_deer/index/models/football_ratio_entity.dart';
import 'package:flutter_gen/gen_l10n/deer_localizations.dart';
import 'package:text_scroll/text_scroll.dart';

class GameUnstartListPage extends StatefulWidget {

  const GameUnstartListPage({
    super.key,
    required this.index,
  });

  final int index;

  @override
  _GameUnstartListPageState createState() => _GameUnstartListPageState();
}

class _GameUnstartListPageState extends State<GameUnstartListPage> with BasePageMixin<GameUnstartListPage, PowerPresenter>, AutomaticKeepAliveClientMixin<GameUnstartListPage> implements GameUnstartIMvpView {

  final _list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0];
  String _orderAmountStr = '';
  late GameUnstartPagePresenter gameUnstartPagePresenter;
  GameUnstartProvider provider = GameUnstartProvider();
  bool? useGiveScoreCheck = false;

  @override
  PowerPresenter<dynamic> createPresenter() {
    final PowerPresenter<dynamic> powerPresenter = PowerPresenter<dynamic>(this);
    gameUnstartPagePresenter = new GameUnstartPagePresenter();
    powerPresenter.requestPresenter([gameUnstartPagePresenter]);
    return powerPresenter;
  }

  @override
  void initState() {
    super.initState();
    if(mounted){
      if(widget.index==0){
        Future.delayed(Duration(seconds: 1),()=>{gameUnstartPagePresenter.getUnstartGameGroupList()});
      }else if(widget.index==1){
        Future.delayed(Duration(seconds: 1),(){
          gameUnstartPagePresenter.getUnstartGameRatioList();
          gameUnstartPagePresenter.getAccountSummary();
        });
      }
    }
    Future.delayed(Duration(seconds: 1),()=>{gameUnstartPagePresenter.computeResidueGiveScore()});
  }

  @override
  void dispose() {
    // provider.dispose();
    super.dispose();
  }

  @override
  void setGameGroups(List<FootballRatioGroupEntity>? list){
    provider.setGameGroups(list);
  }

  @override
  void setRatios(List<FootballGameUnstartEntity>? list){
    provider.setRatios(list);
  }

  @override
  void setResidueGiveScore(double? residueGiveScore){
    provider.setResidueGiveScore(residueGiveScore);
  }

  @override
  void setAccountSummary(AccountSummaryEntity? entity){
    provider.setAccountSummary(entity);
  }

  @override
  void setBettingResult(String? result){
    if(result!='0') {
      showToast('${DeerLocalizations.of(context)!.confirmation.nullSafe}');
      Navigator.of(context).pop();
      gameUnstartPagePresenter.computeResidueGiveScore();
      NavigatorUtils.push(context, IndexRouter.bettingDetailPage,arguments: result);
    }else{
      showToast('${DeerLocalizations.of(context)!.submitFail.nullSafe}');
    }
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return ChangeNotifierProvider<GameUnstartProvider>(
      create: (_) => provider,
      child: Consumer<GameUnstartProvider>(
        builder: (_,provider,child){
          if(widget.index==0){
            if(provider.groupLoading==true){
              return StateLayout(type: StateType.loading);
            }
            if(provider.groupList!.length>0){
              return ListView.builder(
                itemBuilder: (context, index) {
                  FootballRatioGroupEntity groupEntity = provider.groupList!.elementAt(index);
                  if(groupEntity.groupId!=''&&groupEntity.groupId!='0'){
                    return Padding(
                      padding: EdgeInsets.only(top:5,bottom: 5,left: 10,right: 10),
                      child: MyCard(
                        child:  InkWell(
                          onTap: () {
                            NavigatorUtils.push(context, IndexRouter.groupDetailPage,arguments: groupEntity.groupId);
                          },
                            child: Padding(
                              padding: EdgeInsets.symmetric(horizontal: 5,vertical: 10),
                              child: Row(
                                children: [
                                  LoadAssetImage('logo',format:ImageFormat.gif,width:50,height:50),
                                  Expanded(child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Text(groupEntity.title??''),
                                      Gaps.vGap8,
                                      Text('${DeerLocalizations.of(context)!.needToBuy.nullSafe}${groupEntity.ratios!.length}${DeerLocalizations.of(context)!.group.nullSafe}   ${DeerLocalizations.of(context)!.odds.nullSafe}${groupEntity.groupRatio}')
                                    ],
                                  )),
                                  CountdownTimer(
                                    endTime: groupEntity.endBetting,
                                    widgetBuilder: (_, CurrentRemainingTime? time) {
                                      if (time == null) {
                                        return Text('${DeerLocalizations.of(context)!.ended.nullSafe}');
                                      }
                                      String value = '';
                                      if (time.days != null) {
                                        var days = _getNumberAddZero(time.days!);
                                        value = '$value$days ${DeerLocalizations.of(context)!.day
                                            .nullSafe} ';
                                      }
                                      var hours = _getNumberAddZero(time.hours ?? 0);
                                      value = '$value$hours : ';
                                      var min = _getNumberAddZero(time.min ?? 0);
                                      value = '$value$min : ';
                                      var sec = _getNumberAddZero(time.sec ?? 0);
                                      value = '$value$sec';
                                      return Text(value);
                                    },
                                  ),
                                ],
                              ),
                            )
                        )
                      )
                    );
                  }else{
                    FootballGameUnstartEntity item = groupEntity.guessBallNum!;
                    return Padding(
                        padding: EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: MyCard(
                            child: InkWell(
                              onTap: () {
                                gameUnstartPagePresenter.getAccountSummary();
                                provider.setCurrentEntity(item);
                                _showCustomModalBottomSheet(item,provider,false);
                              },
                              child: Padding(
                                  padding: const EdgeInsets.symmetric(
                                      horizontal: 5),
                                  child: Column(
                                      crossAxisAlignment: CrossAxisAlignment
                                          .start,
                                      children: <Widget>[
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceBetween,
                                          children: [
                                            Text(item.name.nullSafe),
                                            CountdownTimer(
                                              endTime: item.endBetting,
                                              widgetBuilder: (_,
                                                  CurrentRemainingTime? time) {
                                                if (time == null) {
                                                  return Text('${DeerLocalizations.of(context)!.ended.nullSafe}');
                                                }
                                                String value = '';
                                                if (time.days != null) {
                                                  var days = _getNumberAddZero(
                                                      time.days!);
                                                  value = '$value$days ${DeerLocalizations.of(context)!.day.nullSafe} ';
                                                }
                                                var hours = _getNumberAddZero(
                                                    time.hours ?? 0);
                                                value = '$value$hours : ';
                                                var min = _getNumberAddZero(
                                                    time.min ?? 0);
                                                value = '$value$min : ';
                                                var sec = _getNumberAddZero(
                                                    time.sec ?? 0);
                                                value = '$value$sec';
                                                return Text(value);
                                              },
                                            ),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                        Divider(height: 1.0, indent: 0.0),
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceAround,
                                          children: [
                                            Container(
                                              width: (MediaQuery.of(context).size.width-80)/2,
                                              child: Column(
                                                children: [
                                                  Image(image: ImageUtils
                                                      .getImageProvider(
                                                      Constant.imageServerHost +
                                                          '${item.teamOne!
                                                              .image}',
                                                      holderImg: 'shop/tx'),
                                                    width: 30,
                                                    height: 30,),
                                                  SizedBox(height: 12,),
                                                  TextScroll(item.teamOne!.name.nullSafe,mode: TextScrollMode.endless,pauseBetween: Duration(milliseconds: 500),)
                                                ],
                                              ),
                                            ),
                                            LoadAssetImage(
                                                'logo', format: ImageFormat.gif,
                                                width: 50,
                                                height: 50),
                                            Container(
                                                width: (MediaQuery.of(context).size.width-80)/2,
                                                child: Column(
                                                  children: [
                                                    Image(image: ImageUtils
                                                        .getImageProvider(
                                                        Constant.imageServerHost +
                                                            '${item.teamTwo!
                                                                .image}',
                                                        holderImg: 'shop/tx'),
                                                      width: 30,
                                                      height: 30,),
                                                    SizedBox(height: 12,),
                                                    TextScroll(item.teamTwo!.name.nullSafe,mode: TextScrollMode.endless,pauseBetween: Duration(milliseconds: 500),)
                                                  ],
                                                )
                                            ),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                        Divider(height: 1.0, indent: 0.0),
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceBetween,
                                          children: [
                                            Text('${DeerLocalizations.of(context)!.numberOfGoalsScored.nullSafe}:' +
                                                item.ratio!.minBallNum.toString()+'-'+item.ratio!.maxBallNum.toString()),
                                            Text('${DeerLocalizations.of(context)!.odds.nullSafe}:' +
                                                item.ratio!.odds.toString()),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                      ]
                                  )
                              ),
                            )
                        )
                    );
                  }
                },
                itemCount: provider.groupList!.length,
              );
            }else {
              return Container(
                width: MediaQuery.of(context).size.width,
                child: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Lottie.asset('assets/lottie/no_football_game.json',width: MediaQuery.of(context).size.width/3,fit: BoxFit.cover),
                      Gaps.vGap8,
                      FadeInText(text: '${DeerLocalizations.of(context)!.noGame.nullSafe}')
                    ],
                  ),
                ),
              );
            }
          }else if(widget.index==1) {
            if (provider.gameStateType == StateType.loading) {
              return StateLayout(type: StateType.loading);
            }
            if (provider.gameList!.length > 0) {
              return DeerListView(
                  itemCount: provider.gameList!.length!,
                  stateType: provider.gameStateType!,
                  onRefresh: _onGameRefresh,
                  loadMore: _loadGameMore,
                  hasMore: false,
                  itemBuilder: (_, index) {
                    FootballGameUnstartEntity item = provider.gameList!
                        .elementAt(index);
                    return Padding(
                        padding: EdgeInsets.only(
                            top: 5, bottom: 5, left: 10, right: 10),
                        child: MyCard(
                            child: InkWell(
                              onTap: () {
                                gameUnstartPagePresenter.getAccountSummary();
                                provider.setCurrentEntity(item);
                                _showCustomModalBottomSheet(item,provider,true);
                              },
                              child: Padding(
                                  padding: const EdgeInsets.symmetric(
                                      horizontal: 5),
                                  child: Column(
                                      crossAxisAlignment: CrossAxisAlignment
                                          .start,
                                      children: <Widget>[
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceBetween,
                                          children: [
                                            Text(item.name.nullSafe),
                                            CountdownTimer(
                                              endTime: item.endBetting,
                                              widgetBuilder: (_,
                                                  CurrentRemainingTime? time) {
                                                if (time == null) {
                                                  return Text('${DeerLocalizations.of(context)!.ended.nullSafe}');
                                                }
                                                String value = '';
                                                if (time.days != null) {
                                                  var days = _getNumberAddZero(
                                                      time.days!);
                                                  value = '$value$days ${DeerLocalizations.of(context)!.day.nullSafe} ';
                                                }
                                                var hours = _getNumberAddZero(
                                                    time.hours ?? 0);
                                                value = '$value$hours : ';
                                                var min = _getNumberAddZero(
                                                    time.min ?? 0);
                                                value = '$value$min : ';
                                                var sec = _getNumberAddZero(
                                                    time.sec ?? 0);
                                                value = '$value$sec';
                                                return Text(value);
                                              },
                                            ),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                        Divider(height: 1.0, indent: 0.0),
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceAround,
                                          children: [
                                            Container(
                                              width: (MediaQuery.of(context).size.width-80)/2,
                                              child: Column(
                                                children: [
                                                  Image(image: ImageUtils
                                                      .getImageProvider(
                                                      Constant.imageServerHost +
                                                          '${item.teamOne!
                                                              .image}',
                                                      holderImg: 'shop/tx'),
                                                    width: 30,
                                                    height: 30,),
                                                  SizedBox(height: 12,),
                                                  TextScroll(item.teamOne!.name.nullSafe,mode: TextScrollMode.endless,pauseBetween: Duration(milliseconds: 500),)
                                                ],
                                              ),
                                            ),
                                            LoadAssetImage(
                                                'logo', format: ImageFormat.gif,
                                                width: 50,
                                                height: 50),
                                            Container(
                                              width: (MediaQuery.of(context).size.width-80)/2,
                                              child: Column(
                                                children: [
                                                  Image(image: ImageUtils
                                                      .getImageProvider(
                                                      Constant.imageServerHost +
                                                          '${item.teamTwo!
                                                              .image}',
                                                      holderImg: 'shop/tx'),
                                                    width: 30,
                                                    height: 30,),
                                                  SizedBox(height: 12,),
                                                  TextScroll(item.teamTwo!.name.nullSafe,mode: TextScrollMode.endless,pauseBetween: Duration(milliseconds: 500),)
                                                ],
                                              )
                                            ),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                        Divider(height: 1.0, indent: 0.0),
                                        SizedBox(height: 5,),
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment
                                              .spaceBetween,
                                          children: [
                                            Text('${DeerLocalizations.of(context)!.score.nullSafe}:' +
                                                item.ratio!.score.toString()),
                                            Text('${DeerLocalizations.of(context)!.odds.nullSafe}:' +
                                                item.ratio!.odds.toString()),
                                          ],
                                        ),
                                        SizedBox(height: 5,),
                                      ]
                                  )
                              ),
                            )
                        )
                    );
                  }
              );
            }else{
              return Container(
                width: MediaQuery.of(context).size.width,
                child: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Lottie.asset('assets/lottie/no_football_game.json',width: MediaQuery.of(context).size.width/3,fit: BoxFit.cover),
                      Gaps.vGap8,
                      FadeInText(text: '${DeerLocalizations.of(context)!.noGame.nullSafe}')
                    ],
                  ),
                ),
              );
            }
          }
          return Container(
            width: MediaQuery.of(context).size.width,
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Lottie.asset('assets/lottie/no_football_game.json',width: MediaQuery.of(context).size.width/3,fit: BoxFit.cover),
                  Gaps.vGap8,
                  FadeInText(text: '${DeerLocalizations.of(context)!.noGame.nullSafe}')
                ],
              ),
            ),
          );
        },
      )
    );
  }

  Future<dynamic> _onGameRefresh() async {
    gameUnstartPagePresenter.initState();
  }

  Future<dynamic> _loadGameMore() async {
  }

  String _getNumberAddZero(int number) {
    if (number < 10) {
      return "0" + number.toString();
    }
    return number.toString();
  }

  void _createOrder(FootballGameUnstartEntity? entity) {
    if(entity!.ratio!.playWay=='2') {
      if (useGiveScoreCheck == true &&
          provider.residueGiveScore! < provider.orderAmount!) {
        showToast('${DeerLocalizations
            .of(context)!
            .orderAmountGreaterGiftAmount
            .nullSafe}');
      } else {
        gameUnstartPagePresenter.saveBetting(
            entity!.ratio!.id.nullSafe, '2', '1',
            useGiveScoreCheck == true ? "2" : "1", provider.orderAmount);
      }
    }else if(entity!.ratio!.playWay=='1'){
      gameUnstartPagePresenter.saveBetting(
          entity!.ratio!.id.nullSafe, '1', '3', '1', provider.orderAmount);
    }
  }

  Future<dynamic> _showCustomModalBottomSheet(FootballGameUnstartEntity? entity,GameUnstartProvider provider,bool useGiveScore) async {
    showModalBottomSheet<void>(
        backgroundColor: context.isDark?Colours.dark_bg_color:Colors.transparent,
        isScrollControlled: true,
        context: context,
        builder: (BuildContext context) {
          return StatefulBuilder(
            builder: (context, setState){
              return BottomSheet(onClosing: (){}, builder: (BuildContext context){
                  return Container(
                      clipBehavior: Clip.antiAlias,
                      decoration: BoxDecoration(
                        color: context.isDark?Colours.dark_bg_color:Colors.transparent,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(20.0),
                          topRight: Radius.circular(20.0),
                        ),
                      ),
                      height: MediaQuery.of(context).size.height / 2.0+200,
                      child: MyScrollView(
                        bottomButton: Padding(
                          padding: const EdgeInsets.only(
                              left: 0.0, right: 0.0, bottom: 0.0),
                          child: Container(
                            color: Theme.of(context).dividerTheme.color,
                            child: GridView.builder(
                                shrinkWrap: true,
                                physics: NeverScrollableScrollPhysics(),
                                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                                  crossAxisCount: 3,
                                  childAspectRatio: 1.953,
                                  mainAxisSpacing: 0.6,
                                  crossAxisSpacing: 0.6,
                                ),
                                itemCount: 12,
                                itemBuilder: (_, index) => _buildButton(index,provider,setState,entity)
                            ),
                          ),
                        ),
                        children: [
                          SizedBox(
                            height: 50,
                            child: Stack(
                              textDirection: TextDirection.rtl,
                              children: [
                                Center(
                                  child: Text(
                                    '${DeerLocalizations.of(context)!.placeAnOrder.nullSafe}',
                                    style: TextStyle(
                                        fontWeight: FontWeight.bold, fontSize: 16.0),
                                  ),
                                ),
                                IconButton(
                                    icon: Icon(Icons.close),
                                    onPressed: () {
                                      Navigator.of(context).pop();
                                    }),
                              ],
                            ),
                          ),
                          Divider(height: 1.0),
                          Visibility(visible: useGiveScore,child: SwitchListTile(value: useGiveScoreCheck!,trackColor: MaterialStateColor.resolveWith((states) => Colours.dark_app_main), onChanged: (val){
                            setState((){
                              useGiveScoreCheck = val;
                            });
                          },title: Text('${DeerLocalizations.of(context)!.useGiftAmount.nullSafe}',style: TextStyle(color: context.isDark?Colours.dark_text:Colours.text)),)),
                          Visibility(visible: useGiveScore,child: TextLabelItem(
                            title: '${DeerLocalizations.of(context)!.residueGiftAmount.nullSafe}',
                            hintText: nf.NumberFormat.decimalPattern('en_us').format(provider.residueGiveScore).toString(),
                          )),
                          TextLabelItem(
                            title: '${DeerLocalizations.of(context)!.allowBettingAmount.nullSafe}',
                            hintText: provider.accountSummaryStateType==StateType.loading?'${DeerLocalizations.of(context)!.dataLoading.nullSafe}':nf.NumberFormat.decimalPattern('en_us').format(provider.accountSummaryData!.allowAntiWaveBettingScore).toString(),
                          ),
                          TextLabelItem(title: '${DeerLocalizations.of(context)!.odds.nullSafe}${entity!.ratio!.odds.toString()}',hintText: provider.willPrizeAmount==0?'${DeerLocalizations.of(context)!.willPrizeAmount.nullSafe}':'${nf.NumberFormat.decimalPattern('en_us').format(provider.willPrizeAmount).toString()}',actionText: '${DeerLocalizations.of(context)!.calculate.nullSafe}',onPressed: (AsyncBtnStatesController btnController){
                            btnController.update(AsyncBtnState.success);
                            },),
                          TextLabelItem(
                            title: '${DeerLocalizations.of(context)!.orderAmount.nullSafe}',
                            hintText: _orderAmountStr.trim()==''?'${DeerLocalizations.of(context)!.inputOrderAmount.nullSafe}':_orderAmountStr.nullSafe,
                          ),
                        ],
                      )
                  );
              });
            },
          );
        }
    ).then((value) {
      provider.resetOrderAmmountStr().then((value) => setState((){
        _orderAmountStr = provider.orderAmountStr.nullSafe==''?'':nf.NumberFormat.decimalPattern('en_us').format(double.parse(provider.orderAmountStr.nullSafe));
      }));
      gameUnstartPagePresenter.getAccountSummary();
    });
  }

  Widget _buildButton(int index,GameUnstartProvider provider,setState,FootballGameUnstartEntity? entity) {
    final color = context.isDark ? Colours.dark_bg_gray : Colours.dark_button_text;
    return Material(
      color: (index == 9 || index == 11) ? color : null,
      child: InkWell(
        child: Center(
          child: index == 9 ? Semantics(
            label: '${DeerLocalizations.of(context)!.delete.nullSafe}',
            child: LoadAssetImage('account/del', width: 32.0),
          ) : index == 11 ? Semantics(
            label: '${DeerLocalizations.of(context)!.ok.nullSafe}',
            child: Text('${DeerLocalizations.of(context)!.ok.nullSafe}'),
          ) : Text(
            _list[index].toString(),
            style: TextStyle(fontSize: 26.0),
          ),
        ),
        onTap: () async {
          if (index == 11) {
            if(_orderAmountStr.trim().nullSafe==''){
              showToast('${DeerLocalizations.of(context)!.inputOrderAmount.nullSafe}');
              return;
            }else{
              _createOrder(entity);
              return;
            }
          }

          if (index == 9) {
            provider.deleteOrderAmountStrByLast().then((value) => {
              setState((){
                _orderAmountStr = provider.orderAmountStr.nullSafe==''?'':nf.NumberFormat.decimalPattern('en_us').format(double.parse(provider.orderAmountStr.nullSafe));
              })
            });
            setState(() {

            });
            return;
          }
            provider.appendOrderAmountStr(_list[index].toString()).then((value) => {
              setState((){
                _orderAmountStr = provider.orderAmountStr.nullSafe==''?'':nf.NumberFormat.decimalPattern('en_us').format(double.parse(provider.orderAmountStr.nullSafe));
              })
            });
        },
      ),
    );
  }

  @override
  bool get wantKeepAlive => false;
}